<template>
  <view>
    <view class="cu-card">
      <view class="cu-item shadow">
        <view class="margin-lr margin-top padding-bottom-sm text-xl solid-bottom">
          <view class="text-xl">
            累计提现：<text class="text-red text-xxl text-bold">{{agentData.extractedIncome}}￥</text>
          </view>
        </view>

        <view>
          <view class="solid-bottom padding flex align-center justify-between" v-for="e in extracts">
            <view class="flex-treble">
              {{parseTime(e.extractTime)}}
            </view>
            <view class="flex-twice text-xl text-red flex justify-center">
              {{e.amount}}￥
            </view>
            <view class="text-grey flex-sub flex justify-end" v-if="e.status === 1">
              审核中
            </view>
            <view class="text-green flex-sub flex justify-end" v-if="e.status === 2">
              已打款
            </view>
            <view class="text-red flex-sub flex justify-end align-center" v-if="e.status === 3" @click="showRejectComment(e)">
              已驳回
            </view>
          </view>
        </view>

        <view class="text-center padding-xs text-gray">
          没有更多了~
        </view>
      </view>
    </view>
  </view>
</template>
<script>
import {request, showToast} from "../../utils/request";
import {parseTime} from "../../utils/date";

export default {
  name: 'extract',
  data() {
    return {
      pageNum: 1,
      pageSize: 100,
      extracts: [],
      agentData: {}
    }
  },
  onLoad() {
    this.getAgentData()
    this.listExtracts()
  },
  methods: {
    parseTime(t) {
      return parseTime(t, '{y}/{m}/{d} {h}:{i}:{s}')
    },
    getAgentData() {
      request({url: '/agent/data'}).then(res => {
        this.agentData = res
      })
    },
    listExtracts() {
      request({url: '/agent/extracts?pageNum=' + this.pageNum + '&pageSize=' + this.pageSize}).then(res => {
        this.extracts = res.list
      })
    },
    showRejectComment(e) {
      showToast(e.rejectComment)
    }
  }
}
</script>
<style>
</style>
